package com.mo.sys.web.controller;

import com.mo.common.util.PageUtil;
import com.mo.sys.pojo.SysLog;
import com.mo.sys.service.SysLogService;
import com.mo.sys.web.pojo.LogJsonResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/log/")
public class SysLogController {


    @Autowired
       private SysLogService sysLogService;
    //构造方法注入
  //sLogService){
       // this.sysLogService=sysLogService;
  //  }



    @GetMapping
    public LogJsonResult doFindLogs(SysLog sysLog){
        return  new LogJsonResult(PageUtil.startPage()
                .doSelectPageInfo(()->

                        sysLogService.findLogs(sysLog)
               ));
    }


    @GetMapping("{id}")
     public LogJsonResult doFindById(@PathVariable Long id)
            throws Exception {

            return new LogJsonResult(sysLogService.findById(id));

     }

     /*
     @PostMapping
     public LogJsonResult dosaveLogs(@RequestBody SysLog sysLog){
         sysLogService.savelogs(sysLog);
            return new LogJsonResult("save ok");
     }
      */

     @DeleteMapping("{id}")
     public LogJsonResult dodeleteLogs(@PathVariable Long...id) throws Exception {
         sysLogService.deleteById(id);
            return  new LogJsonResult("delete ok");
     }
}
